package cn.longge.mapper;

import cn.longge.entity.SysOffice;
import cn.longge.entity.SysResource;
import cn.longge.entity.SysRole;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface SysRoleMapper extends Mapper<SysRole> {

    @SelectProvider(value = SysRoleSqlProvider.class,method = "selectRoleAndOffice")
    List<SysRole> selectRoleAndOffice(Map<String,Object> params);

    @DeleteProvider(value = SysRoleSqlProvider.class,method = "deleteByUserIds")
    int deleteByUserIds(@Param("rid") Long rid,@Param("ids") List<Long> ids);

    @InsertProvider(value = SysRoleSqlProvider.class,method = "insertMany")
    int insertMany(@Param("rid")Long rid,@Param("addIds") List<Long> addIds);

    @InsertProvider(value = SysRoleSqlProvider.class,method = "insertRoleResource")
    int insertRoleResource(@Param("roleId") long roleId, @Param("resources")List<SysResource> resources);

    @Delete("delete from sys_role_resource where role_id = #{rid}")
    int deleteFromSRR(long rid);

    @InsertProvider(value = SysRoleSqlProvider.class,method = "insertRoleOffice")
    int insertRoleOffice(@Param("roleId") long roleId, @Param("offices")List<SysOffice> offices);

    @Delete("delete from sys_role_office where role_id = #{rid}")
    int deleteFromSRO(long rid);
}